#include "CSetColorAttributeCommand.h"
#include "CUserInterface.h"
#include "CLevelEditor.h"
#include "CSceneObject.h"
#include "IAttributes.h"


extern CGlobals* g;
extern CUserInterface* ui;
extern CLevelEditor* editor;

CSetColorAttributeCommand::CSetColorAttributeCommand (int id, stringc name, irr::video::SColor newColor)
{
	m_id = id;
	m_name = name;
	m_oldColor = editor->getSceneObjectFromID(id)->m_UserData->getAttributeAsColor(name.c_str());
	m_newColor = newColor;
	setDescription(stringw(L"change ") + name.c_str());
}

void CSetColorAttributeCommand::redo ()
{
	editor->getSceneObjectFromID(m_id)->m_UserData->setAttribute(m_name.c_str(), m_newColor);
}

void CSetColorAttributeCommand::undo ()
{
	editor->getSceneObjectFromID(m_id)->m_UserData->setAttribute(m_name.c_str(), m_oldColor);
}
